package org.springcloud.wisdom.springcloud_03_freshman.admin.dao;

import org.apache.ibatis.annotations.*;
import org.springcloud.wisdom.springcloud_03_freshman.student.entity.Card;
import org.springcloud.wisdom.springcloud_03_freshman.student.entity.Dept;
import org.springcloud.wisdom.springcloud_03_freshman.student.entity.Dormitory;

import java.util.List;

@Mapper
public interface AdminDormDao {
    //增加
    @Insert("insert into dormitory (position,dorno,type,contain,attri,occupy) values " +
            "(#{position},#{dorno},#{type},#{contain},#{attri},#{occupy})")
    public int addDorm(Dormitory dormitory);


    //查看
    @Select("select * from dormitory  limit  #{start},#{size}")
    public List<Dormitory> getAll(int start, int size);
    @Select("select count(*) from dormitory")
    public int countCards();

    //修改 attri occupy
    @Update("<script>" +
            "update dormitory" +
            "        <set>" +
            "            <if test=\"null!= occupy\">" +
            "                occupy =#{occupy}," +
            "            </if>" +
            "            <if test=\"null!= attri\">" +
            "                attri =#{attri}," +
            "            </if>" +
            "        </set>" +
            "        where id =#{id}" +
            "</script>")
    public int updateDorm(Dormitory dormitory);
}
